(function (win, angular) {
    "use strict";
    angular.module('app')
        .directive('drawChart', ['$templateCache','$compile',
            function ($templateCache,$compile) {
                return {
                    scope : {
                        conf                : "="
                    },
                    restrict : 'A',
                    replace:true,
                    link: function ($scope,$elem) {
                       var myChart = echarts.init($elem.context),option;
                        option = {
                    		    tooltip: {
                    		        trigger: 'item',
                    		        formatter: "{a} <br/>{b}: {c} ({d}%)"
                    		    },
                    		    color:$scope.conf.colors
                    		    /*,
                    		    legend: {
                    		        orient: 'vertical',
                    		        x: 'left',
                    		        data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
                    		    }*/,
                    		    series: [
                    		        {
                    		            name:$scope.conf.name,
                    		            type:$scope.conf.type,
                    		            radius:$scope.conf.radius,
                    		            avoidLabelOverlap: false,
                    		            label: {
                    		                normal: {
                    		                    show:true,
                    		                    position: $scope.conf.labelPos,
                    		                    textStyle:{
                    		                    	fontFamily:'Microsoft Yahei',
                    		                    	fontSize: 12,
                    		                    	fontStyle:'oblique',
                    		                    	color: '#333'
                    		                    }
                    		                },
                    		                emphasis: {
                    		                    show: true,
                    		                    textStyle: {
                    		                    	fontFamily:'Microsoft Yahei',
                    		                    	fontSize: 12,
                    		                    	fontStyle:'oblique',
                    		                    	color: '#333'
                    		                    }
                    		                }
                    		            },
                    		            labelLine: {
                    		                normal: {
                    		                    show: true
                    		                }
                    		            },
                    		            data:$scope.conf.data
                    		        }
                    		    ]
                    		};
                       myChart.setOption(option);
                    }
                };
            }])
    ;
})(window, window.angular);
